<template>
  <Head />
  <div class="invitation">
    <div class="head-wrapper">
      <h1 class="heading">{{ $t("menu3") }}</h1>
      <p class="paragraph">{{ $t("invitationTips1") }}</p>
    </div>
    <div class="bg-image"></div>
    <div class="card-wrapper">
      <div class="card">
        <div class="title">{{ $t("invitation") }}</div>
        <p class="tips">
          {{ $t("invitationTips2") }}
        </p>
        <div class="copy">{{ $t("copyLink") }}</div>
        <div class="container">
          <input type="text" class="card-input" :value="inviteCode" :disabled="true" />
          <!-- <img src="@/assets/image/copy.svg" @click="onCopy()" />  -->
          <div class="copy1" @click="onCopy()" >{{$t('copy')}}</div>
        </div>
      </div>
    </div>
    <div class="gradient-bg"></div>
  </div>
  <Footer />
</template>

<script setup lang="ts">  
import { showToast } from "vant";
import clipboard3 from "vue-clipboard3";
import { userStore } from "@/stores/modules/user";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const inviteCode = userStore().info.user?.inviteCode
const { toClipboard } = clipboard3();
const onCopy = async () => {
  await toClipboard(
    `${window.location.host}/home?inviteCode=${inviteCode}`
  );
  showToast(t("copySuccess"));
};
</script>
<style scoped lang="scss">
$theme: #59e457;

.invitation {
  height: 100vh;
}

.head-wrapper {
  align-items: center;
  background: radial-gradient(50% 50% at 50% 0, #59e4574d 0, #59e45700 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  top: 56px;

  .heading {
    word-wrap: break-word;
    color: $theme;
    font-family: Ethnocentric;
    font-size: 20px;
    font-weight: 400;
    line-height: 20px;
    margin-bottom: 0.5rem;
    padding-top: 25px;
  }

  .paragraph {
    word-wrap: break-word;
    color: #fff;
    font-family: Inter-Regular;
    font-size: 15px;
    font-weight: 400;
    margin-top: 0;
  }
}

.bg-image {
  background-color: #000;
  background-image: url("@/assets/image/invitationBg.png");
  background-repeat: no-repeat;
  height: 36vh;
}

.card-wrapper {
  width: 100%;
  margin-left: auto;
  box-sizing: border-box;
  margin-right: auto;
  display: block;
  padding-left: 32px;
  padding-right: 32px;

  .card {
    padding: 16px 16px 28px 16px;
    background: #1a1d1a;
    border: 1px solid #1a1d1a;
    border-radius: 5px;
    position: relative;
    width: 100%;
    z-index: 1;
    color: white;
    overflow: hidden;
    min-width: 275px;

    .title {
      font-family: Inter-Regular;
      font-weight: 600;
      font-size: 1.25rem;
      line-height: 1.6;
      letter-spacing: 0.0075em;
    }

    .tips {
      word-wrap: break-word;
      color: #fff;
      font-family: Inter-Regular;
      font-size: 13px;
      font-weight: 400;
      line-height: 1.5;
      letter-spacing: 0.00938em;
    }

    .copy {
      word-wrap: break-word;
      color: #fff;
      font-family: Inter-Regular;
      font-size: 15px;
      margin-bottom: -25px;
      margin-top: 15px;
      line-height: 1.6;
      letter-spacing: 0.0075em;
    }

    .container {
      display: flex;
      justify-content: space-between;
      margin-top: 2rem;

      .card-input {
        background: #000000b3;
        border: 1px solid $theme;
        border-radius: 5px;
        color: #fff;
        padding: 7px;
        height: 40px;
        width: 95%;
      }

      img {
        margin-left: 16px;
      }
    }
  }
}

.gradient-bg {
  background: radial-gradient(60% 40% at 50% 50%, #59e4574d 0, #59e45700 100%);
  border-radius: 9999px;
  height: 35%;
  position: absolute;
  top: 380px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
}
.copy1{
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: #fff;
  width: 20%;
}
</style>
